<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.pollix.org/thymeleaf/shiro">
<head>
    <meta charset="utf-8">
    <title>未分配列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<input type="hidden" id="userName" th:value="${session.USER_SESSION.realname}"><!--这个隐藏域 获得当前用户的用户名，这个用在删除时，必须是当前用户是要删除的销售机会的创建人，否则无法删除-->
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input searchVal" placeholder="请输入搜索的内容" />
                </div>
                <a class="layui-btn search_btn" data-type="reload">搜索客户</a>
            </div>


        </form>
    </blockquote>
    <table id="saleChanceList" lay-filter="saleChance"></table>

    <!--导出excel按钮-->
    <script type="text/html" id="data-toolbar">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="export" id="exportFile">Excel导出</button>
        </div>
    </script>


<script type="text/javascript" src="resources/layui/layui.js"></script>
<!--导出excel需要-->
<script type="text/javascript" src="resources/layui/layui_exts/excel.js"></script>
<script th:inline="none">
    layui.use(['form','layer','laydate','table','laytpl'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table;
        //客户机会列表
        var tableIns = table.render({
            elem: '#saleChanceList',
            url : 'noAssignSaleChance',
            page : true,
            height : "full-125",
            limit : 8,
            limits : [8,10,15,20,25],
            id : "saleChanceListTable",
            toolbar: "#data-toolbar",
            defaultToolbar: ['filter', 'print', 'exports'],
            totalRow: true,
            title: '数据表',
            cols : [[
                {type: "checkbox", fixed:"left"},
                {field: 'chanNo', title: '编号',align:"center"},
                {field: 'chanCustName', title: '客户名称',align:"center"},
                {field: 'chanLinkman', title: '联系人', align:"center"},
                {field: 'chanTelephone', title: '联系人电话', align:"center"},
                {field: 'chanCreateBy', title: '创建人', align:"center"},//后面加的，如果有错误就是这句话错了，没加之前所有都是正常的
                {field: 'chanCreateDate', title: '创建时间', align:"center"},
                {field: 'chanStatus', title: '状态',align:"center",templet:function (row) {
                        // lay-event="forbidden"
                        if(row.chanStatus==1){return "未指派"}
                        else if (row.chanStatus==2){return "已指派"}
                        else if (row.chanStatus==3){return "已归档开发失败"}
                        else if (row.chanStatus==4){return "已经归档开发成功"}
                }},
            ]],
        });

        /*导出数据*/
        $('#exportFile').on('click',function () {
            console.info("export");
            $.ajax({
                url: "noAssignSaleChance",
                type: 'get',
                async: false,
                dataType: 'json',
                success: function (res) {
                    LAY_EXCEL.exportExcel(res.data, 'data.xlsx', 'xlsx')
                }
            });
        });


        //搜索客户
        $(".search_btn").on("click",function(){
            table.reload("saleChanceListTable",{//更新客户机会列表
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    chanCustName: $(".searchVal").val()  //搜索的关键字
                }
            })
        });
    })

</script>
</body>
</html>